package cn.tedu.hm.service.impl;

import cn.tedu.hm.ex.ServiceException;
import cn.tedu.hm.mapper.SalaryShowMapper;
import cn.tedu.hm.pojo.entity.SalaryShow;
import cn.tedu.hm.pojo.vo.SalaryShowListItemVO;
import cn.tedu.hm.service.ISalaryShowService;
import cn.tedu.hm.wep.ServiceCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * tj41h
 */
@Slf4j
@Service
public class SalaryShowImpl implements ISalaryShowService {

    @Autowired
    private SalaryShowMapper salaryShowMapper;

    @Override
    public List<SalaryShowListItemVO> list() {
        log.debug("开始处理【当月工资列表】的业务，无参数");
        List<SalaryShowListItemVO> list = salaryShowMapper.list();
        for(SalaryShowListItemVO sala:list){
            sala.setSaleCount(sala.getSalary()+sala.getPerformance());
        }
        if (list == null) {
            // 是：抛出异常
            String message = "数据不存在！";
            log.warn(message);
            throw new ServiceException(ServiceCode.ERROR_NOT_FOUND, message);
        }
        return list;
    }
}
